/*
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* openUBMC is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*         http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

#ifndef MC_TESTS_DRIVERS_PCIE_NIC_CARD_MELLANOX_INTERFACE_MOCK_IPMI_CORE_H
#define MC_TESTS_DRIVERS_PCIE_NIC_CARD_MELLANOX_INTERFACE_MOCK_IPMI_CORE_H

#include <mc/engine.h>
#include <mc/common.h>
#include <mc/variant.h>
#include <vector>

namespace drivers {
namespace pcie_nic_card {
namespace mellanox {
namespace interface {
namespace test {

// Mock IPMI Core 接口，避免真实的 D-Bus 调用
class test_ipmi_core_interface : public mc::engine::interface<test_ipmi_core_interface> {
public:
    MC_INTERFACE("bmc.kepler.IpmiCore")

    // a{ss}yyyyyay
    mc::variant Request(
        const mc::dict& ctx,              // a{ss} - 上下文字典
        uint8_t channel_type,              // y - 通道类型
        uint8_t instance,                  // y - 实例序号
        uint8_t net_fn,                   // y - 网络功能码
        uint8_t lun,                      // y - 逻辑单元号
        uint8_t cmd,                      // y - 命令字
        const std::vector<uint8_t>& data  // ay - 命令参数数据
    ) {
        ilog("test_ipmi_core_interface: Request - net_fn=${net_fn}, cmd=${cmd}", ("net_fn", net_fn)("cmd", cmd));
        // 返回模拟的成功响应，避免真实的 D-Bus 调用
        mc::variants result = {mc::variant(static_cast<int64_t>(0)), mc::variant(std::vector<uint8_t>{0x00, 0x01, 0x02})};
        return mc::variant(result);
    }
};

class test_ipmi_core_object : public mc::engine::object<test_ipmi_core_object> {
public:
    MC_OBJECT(test_ipmi_core_object, "bmc.kepler.IpmiCore", "/bmc/kepler/IpmiCore", (test_ipmi_core_interface))

    test_ipmi_core_interface m_test_interface;
};

} // namespace test
} // namespace interface
} // namespace mellanox
} // namespace pcie_nic_card
} // namespace drivers

#endif // MC_TESTS_DRIVERS_PCIE_NIC_CARD_MELLANOX_INTERFACE_MOCK_IPMI_CORE_H

